package com.loanly.view;

import java.util.List;

import com.loanly.controller.LoanManager;
import com.loanly.model.Loan;
 
import com.opensymphony.xwork2.ActionSupport;
 
 
public class LoanAction extends ActionSupport {
 
    /**
	 * 
	 */
	private static final long serialVersionUID = -2325759296649094711L;
	private Loan loan;
    private List<Loan> loanList;
    private Long loansid;
//    private Double sumAmount;
 
    private LoanManager loanManager;
 
    public LoanAction() {
    	loanManager = new LoanManager();
    }
 
    public String execute() {
        this.loanList = loanManager.list();
        //this.setSumAmount(loanManager.getSumAmount());
        System.out.println("LoanAction execute called");
        return SUCCESS;
    }
 
    public String add() {
//        System.out.println(getLoan().getActive());
//        System.out.println(getLoan().getFirstname());
        try {
        	loanManager.add(getLoan());
        } catch (Exception e) {
            e.printStackTrace();
        }
        this.loanList = loanManager.list();
        return SUCCESS;
    }
 
    public String delete() {
    	loanManager.delete(getLoan_id());
        return SUCCESS;
    }
 
    public Loan getLoan() {
    	//System.out.println("loan��firstname == " + loan.getFirstName());
        return loan;
    }
 
    public List<Loan> getLoanList() {
        return loanList;
    }
 
    public void setLoan(Loan loan) {
        this.loan = loan;
    }
 
    public void setLoanList(List<Loan> loansList) {
        this.loanList = loansList;
    }
 
    public Long getLoan_id() {
        return loansid;
    }
 
    public void setId(Long loansid) {
        this.loansid = loansid;
    }

}